package com.hzhc.controller.chargeBill;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hzhc.annotation.SysTemLog;
import com.hzhc.common.BaseController;
import com.hzhc.enumBean.ResultUtilCodeEnum;
import com.hzhc.service.ChargeBillService;
import com.hzhc.utils.ResultUtil;
import com.hzhc.vo.ChargeBillVo;
import lombok.RequiredArgsConstructor;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * 费用账单 前端控制器
 * </p>
 *
 * @author 功不唐捐
 * @since 2024-06-12
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/chargeBill")
public class ChargeBillController extends BaseController {

    private final ChargeBillService chargeBillService;


    /**
     * 流水页面列表
     */
    @RequestMapping("/getChargeBillList")
    @ResponseBody
    public ResultUtil<List<ChargeBillVo>> getChargeBillList(@RequestBody ChargeBillVo vo) {
        Page<ChargeBillVo> pagination = new Page<>(vo.getPageIndex(), vo.getPageSize());
        List<ChargeBillVo> chargeBillVos = chargeBillService.getChargeBillListPage(vo, pagination);
        return ResultUtil.build(chargeBillVos, pagination.getTotal(),pagination.getPages(), ResultUtilCodeEnum.SUCCESS);
    }

    /**
     * 费用流水总账单添加
     */
    @PostMapping("/addBillRet")
    @SysTemLog(operModul = "计费管理-费用流水账单生成", operType = "账单生成", operDesc = "费用流水账单生成", modular="PC")
    public ResultUtil<T> addBillRet(HttpServletRequest request, @RequestBody ChargeBillVo vo) {
        return chargeBillService.addBillRet(request,vo);
    }

    /**
     * 总账单退费
     */
    @PostMapping("/backBillRet")
    @SysTemLog(operModul = "计费管理-费用流水账单退费", operType = "账单退费", operDesc = "费用流水账单退费", modular="PC")
    public ResultUtil<T> backBillRet(HttpServletRequest request, @RequestBody ChargeBillVo vo) {
        return chargeBillService.backBillRet(request,vo);
    }

    /**
     * 总账单审核
     */
    @PostMapping("/checkBillRet")
    @SysTemLog(operModul = "计费管理-费用流水账单审核", operType = "账单审核", operDesc = "费用流水账单审核", modular="PC")
    public ResultUtil<T> checkBillRet(HttpServletRequest request, @RequestBody ChargeBillVo vo) {
        return chargeBillService.checkBillRet(request,vo);
    }
}
